﻿namespace WeDonekRpc.CacheClient.Config
{
    public enum RedisCommandMap
    {
        Default = 0,
        Twemproxy = 1,
        Envoyproxy = 2,
        SSDB = 3,
        Sentinel = 4,
    }
    public enum RedisFailFast
    {
        FailFast = 0,
        Default = 1,
    }
    /// <summary>
    /// Redis配置
    /// </summary>
    public class RedisConfig
    {
        /// <summary>
        /// 
        /// </summary>
        public RedisCommandMap CommandMap { get; set; } = RedisCommandMap.Default;
        /// <summary>
        /// 连接字符串
        /// </summary>
        public string ConString
        {
            get;
            set;
        }
        /// <summary>
        /// 默认DB
        /// </summary>
        public int DefaultDatabase
        {
            get;
            set;
        } = 0;
        /// <summary>
        /// 是否应允许管理操作
        /// </summary>
        public bool AllowAdmin
        {
            get;
            set;
        } = true;
        /// <summary>
        /// Ping间隔
        /// </summary>
        public int KeepAlive
        {
            get;
            set;
        } = 60;
        /// <summary>
        /// 链接重试次数
        /// </summary>
        public int ConnectRetry
        {
            get;
            set;
        } = 5;
        /// <summary>
        /// 同步超时
        /// </summary>
        public int SyncTimeout
        {
            get;
            set;
        } = 5000;
        /// <summary>
        /// 异步超时
        /// </summary>
        public int AsyncTimeout
        {
            get;
            set;
        } = 5000;
        /// <summary>
        /// 链接超时
        /// </summary>
        public int ConnectTimeout
        {
            get;
            set;
        } = 5000;

        /// <summary>
        /// 链接地址
        /// </summary>
        public string[] ServerIp
        {
            get;
            set;
        }
        /// <summary>
        /// 登陆名
        /// </summary>
        public string UserName
        {
            get;
            set;
        }
        /// <summary>
        /// 密码
        /// </summary>
        public string Pwd
        {
            get;
            set;
        }

        /// <summary>
        /// 是否检查证书吊销列表
        /// </summary>
        public bool CheckCertificateRevocation { get; set; } = false;
        /// <summary>
        /// 用于通过sentinel解析服务的服务名称。
        /// </summary>
        public string ServiceName { get; set; }
        /// <summary>
        /// 获取或设置库是否应通过库名称/版本标识自身
        /// </summary>
        public bool SetClientLibrary { get; set; } = true;
        /// <summary>
        /// 每隔n秒（默认情况下每分钟）检查一次配置
        /// </summary>
        public int ConfigCheckSeconds { get; set; } = 60;
        /// <summary>
        /// 用于广播和收听配置更改通知的频道
        /// </summary>
        public string ConfigurationChannel { get; set; }
        /// <summary>
        /// 连接不正常时用于命令的囤积策略。
        /// </summary>
        public RedisFailFast BacklogPolicy { get; set; }
        /// <summary>
        /// 心跳间隔
        /// </summary>
        public int HeartbeatInterval { get; set; } = 2;
        /// <summary>
        /// 例外情况是否应包括可识别的详细信息？（密钥名称，附加。数据
        /// </summary>
        public bool IncludeDetailInExceptions { get; set; } = true;
        /// <summary>
        /// 异常是否应包括性能计数器详细信息？
        /// </summary>
        public bool IncludePerformanceCountersInExceptions { get; set; } = false;
        /// <summary>
        /// 获取或设置要用于CLIENT SETINFO库名称调用Redis的库名称
        /// </summary>
        public string LibraryName { get; set; }
        /// <summary>
        /// 用于在初级之间进行选择的平局决胜局
        /// </summary>
        public string TieBreaker { get; set; } = "__Booksleeve_TieBreak";
        /// <summary>
        /// 指示在连接之前是否应通过DNS解析终结点
        /// </summary>
        public bool ResolveDns { get; set; }
    }
}
